package Utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.junit.Test;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

/**
 * @Author Chen
 * @Date 2021/12/19 17:37
 * @Version 1.0
 */
public class DruidTest {

    @Test
    public Connection getConnection() throws Exception {
        Properties pros =  new Properties();
        InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("druid.properties");
        pros.load(is);
        DataSource source = DruidDataSourceFactory.createDataSource(pros);
        Connection conn = source.getConnection();
        return conn;
    }
}
